
#ifndef TCONFIG_H
#define TCONFIG_H

#include <windows.h>
#include <typeinfo.h>
#include <time.h>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#include <gdiplus.h>
#pragma comment(lib,"Msimg32.lib")
#pragma comment(lib,"gdiplus.lib")
using namespace Gdiplus;
#define degree2Radian(degree) degree/180*3.1415926f

static const int WIN_WIDTH		 = 1366;
static const int WIN_HEIGHT		 = 768;	
static const int FRAME_SPEED	 = 100;	
static const int MENU_WIDTH		 = 200;
static const int MENU_HEIGHT	 = 60;
static const int MENU_SPACE		 = 10;
static const int MENU_ALPHA		 = 180;
static const COLORREF MENU_BKCLR = RGB(0, 0, 0);
static const int LAYER_MAX		 = 1000;
static const LPCTSTR WIN_CLASS	 = TEXT("Final Engine");
static const LPCTSTR WIN_TITLE	 = TEXT("Final Engine Ver0.0");

typedef unsigned short ushort;

enum GAME_STATE
{
	GAME_START,
	GAME_RUN,
	GAME_PAUSE,
	GAME_UPGRADE,
	GAME_WIN,
	GAME_OVER,
	GAME_HELP,
	GAME_ABOUT,
	GAME_SETTING
};
 
enum KM_ACTION
{
	KEY_SYS_NONE,
	KEY_UP,
	KEY_DOWN,
	MOUSE_MOVE,
	MOUSE_LCLICK,
	MOUSE_RCLICK
};

enum LAYER_TYPE
{
	LAYER_PLY,
	LAYER_NPC,
	LAYER_PLY_BOMB,
	LAYER_NPC_BOMB,
	LAYER_MAP_BACK,
	LAYER_MAP_BARR,
	LAYER_MAP_MASK,
	LAYER_EXPLOSION,
	LAYER_TARGET,
	LAYER_BONUS,
	LAYER_NONE
};

typedef struct
{
	int		X;
	int		Y;
	int		Dir;
	int		Speed;
	int		Level;
	int		Score; 
	bool	Visible;
	bool	Active;
	bool	Dead;
	BYTE	Alpha;
	float	Ratio;
	int		Rotation;
}SPRITEINFO;

typedef struct
{
	int		map_type;
	int		map_width;
	int		map_height;
	int		map_cols;
	int		map_rows;
	int		tile_width;
	int		tile_height;
	int zOrder;
	string	graph;
}LAYERINFO;

typedef struct  
{
	POINT pos;
	wstring ItemName;
}MENUITEM;

typedef struct  
{
	int		width;
	int		height;
	int		space;
	int		align;
	LPCTSTR fontName;
	bool	isBold;
	Color	normalTextColor;
	Color	focusTextColor;
}MENU_INFO;


typedef struct tagBounds{
	int x,y;
	int width,height;
}Bounds,pBounds;

typedef struct tagPoint{
	int x,y;
}iPoint,*pIPoint;

const float East=0,Northeast=45,
	North=90,Northwest=90+45,
	West=180,Southwest=180+45,
	South=270,Southeast=270+45;
/*
#define COLLIDE 0x8100
#define OVER 0x8001
#define COLLIOVER 0x8101
#define NONE 0x8000
*/
typedef struct tagTile{
	short x,y;
	ushort tileIndex;
	bool operator==(struct tagTile t) const{
		return x==t.x && y==t.y && tileIndex==t.tileIndex;
	}
}Tile;
typedef vector<Tile>Tiles;
typedef map<string,Tiles*>MapSection;

#define C_TOP 0xF0
#define C_BOTTOM 0x0F
#define C_LEFT 0xF0
#define C_RIGHT 0x0F
#define C_NONE 0x00

#define C_TOP_NONE 0xF000
#define C_TOP_LEFT 0xF0F0
#define C_TOP_RIGHT 0xF00F

#define C_BOTTOM_NONE 0x0F00
#define C_BOTTOM_LEFT 0x0FF0
#define C_BOTTOM_RIGHT 0x0F0F

#define C_NONE_LEFT 0x00F0
#define C_NONE_RIGHT 0x000F
#define C_NONE_NONE 0x0000

typedef unsigned short COLLIDERESULT;

const int TOP=3,BOTTOM=2,LEFT=1,RIGHT=0;


#define isCollide(result,index) (result>>(index<<2))&0x1
void grant(COLLIDERESULT &value,int index);
void revoke(COLLIDERESULT &value,int index);
void add(COLLIDERESULT & a,const COLLIDERESULT b);
#endif
